This report describes the results of the first priming mindfulness study, as well as of the two online pilot studies from the Varela project. It was made using Dominique Makowski’s Supplementary Materials template (click “visit website” above for info).
library(rempsyc)
library(dplyr)
library(interactions)
library(performance)
library(see)
library(patchwork)
library(ggplot2)
library(rstatix)
library(forecast)
library(DescTools)
library(report)
library(bestNormalize)
summary(report::report(sessionInfo()))The analysis was done using the R Statistical language (v4.2.0; R Core Team, 2022) on Windows 10 x64, using the packages bestNormalize (v1.8.2), DescTools (v0.99.44), effectsize (v0.6.0.7), ggplot2 (v3.3.5), forecast (v8.16), rmarkdown (v2.13), interactions (v1.1.5), parameters (v0.17.0.5), insight (v0.17.0), performance (v0.9.0), see (v0.7.0), easystats (v0.4.3), correlation (v0.8.0), modelbased (v0.8.0), bayestestR (v0.11.5.2), report (v0.5.1), datawizard (v0.4.0), tidyverse (v1.3.1), dplyr (v1.0.8), forcats (v0.5.1), patchwork (v1.1.1), purrr (v0.3.4), readr (v2.1.2), rempsyc (v0.0.3.3), rstatix (v0.7.0), stringr (v1.4.0), tibble (v3.1.6) and tidyr (v1.2.0).
df <- read.csv("data/data.csv")
data <- read.csv("data/fulldataset.csv")
cat(paste("The data consists of",
report::report_participants(data),
". There are no demographics available."))The data consists of 245 participants () . There are no demographics available.
# Dummy-code group variable
data <- data %>%
mutate(condition_dum = ifelse(condition == "Mindfulness", 1, 0),
condition = as.factor(condition))
# Allocation ratio
cat(paste("The allocation ratio is: ",
report::report(data$condition)))The allocation ratio is: x: 2 levels, namely Control (n = 128, 52.24%) and Mindfulness (n = 117, 47.76%)
In this stage, we define a list of our relevant variables and standardize them according to the Median Absolute Deviation (MAD), which is more robust to extreme observations than standardization around the mean.
# Make list of DVs
col.list <- c("blastintensity", "blastduration", "blastintensity.duration",
"blastintensity.first", "blastduration.first",
"blastintensity.duration.first", "KIMS", "BSCS", "BAQ",
"SOPT", "IAT")
# Create new variable blastintensity.duration
data$blastintensity.duration <- (data$blastintensity * data$blastduration)
data$blastintensity.duration.first <- (data$blastintensity.first *
data$blastduration.first)
# Divide by 2? Do some other sort of transformation given I multiplied two scores?
# Should I multiply them after standardization or before?
# Standardize and center main continuous IV variable (based on MAD)
# data <- data %>%
# mutate(across(all_of(col.list),
# ~as.numeric(.x), #scale_mad(.x),
# .names = "{col}.mad"))
# We avoid standardizing now because it creates problems with the bestNormalize() function, and the latter also standardize variables anyway (although not based on mad...)
# Rename col.list with the MAD extension
# col.list <- paste0(col.list, ".mad")Why combine the intensity and duration scores? Should we? For a discussion, see:
Elson, M., Mohseni, M. R., Breuer, J., Scharkow, M., & Quandt, T. (2014). Press CRTT to measure aggressive behavior: the unstandardized use of the competitive reaction time task in aggression research. Psychological assessment, 26(2), 419. https://doi.org/10.1037/a0035569
Why use the first sound blast only instead of the average of all trials? Should we?
According to some, the Taylor Aggression Paradigm is not a measure of aggression per say, but of reactive aggression, because participants react to the other “participant’s” aggression. They suggest that for a pure measure of aggression, it is recommended to use only the first sound blast used by the participant before he receives one himself. At this stage, we attempt the analyses with all these different measures of aggression for exploratory purposes. See earlier reference to Elson et al. (2014):
In this section, we will: (a) test assumptions of normality, (b) transform variables violating assumptions, (c) test assumptions of homoscedasticity, (d) identify and winsorize outliers, and (e) conduct the t-tests.
# Group normality
sapply(col.list, function(x)
nice_normality(data,
x,
"condition",
shapiro = TRUE,
title = x),
USE.NAMES = TRUE,
simplify = FALSE)> $blastintensity
>
> $blastduration
>
> $blastintensity.duration
>
> $blastintensity.first
>
> $blastduration.first
>
> $blastintensity.duration.first
>
> $KIMS
>
> $BSCS
>
> $BAQ
>
> $SOPT
>
> $IAT
Several variables are clearly skewed. Let’s apply transformations.
# <!-- Normally, the SOPT raw scores represent the number of errors, but I had multiplied it by -1 initially so that a smaller score would mean lower working memory capacity. Here we reverse it again to be able to use the various transformations. -->
#
# <!-- We also add a constant of 1 to avoid scores of zero which can interfere with the transformation. We will use the Box-Cox transformation to be able to specify an optimal transformation ratio. -->
# Not necessary anymore since we use the `bestNormalize` package.The command below transforms variables according to the best possible
transformation (via the bestNormalize package), and also
standardize the variables.
predict_bestNormalize <- function(var, print.transform = TRUE) {
x <- bestNormalize(var, standardize = TRUE)
if (print.transform == TRUE) {
print(cur_column())
print(x$chosen_transform)
}
predict(x)
}
set.seed(100)
data <- data %>%
mutate(across(all_of(col.list),
predict_bestNormalize,
.names = "{.col}.BN"))> [1] "blastintensity"
> orderNorm Transformation with 245 nonmissing obs and ties
> - 142 unique values
> - Original quantiles:
> 0% 25% 50% 75% 100%
> 0.0 3.0 4.8 6.0 10.0
> [1] "blastduration"
> orderNorm Transformation with 245 nonmissing obs and ties
> - 201 unique values
> - Original quantiles:
> 0% 25% 50% 75% 100%
> 0 793 1100 1300 2000
> [1] "blastintensity.duration"
> Standardized sqrt(x + a) Transformation with 245 nonmissing obs.:
> Relevant statistics:
> - a = 0
> - mean (before standardization) = 69
> - sd (before standardization) = 33
> [1] "blastintensity.first"
> orderNorm Transformation with 245 nonmissing obs and ties
> - 11 unique values
> - Original quantiles:
> 0% 25% 50% 75% 100%
> 0 3 7 9 10
> [1] "blastduration.first"
> center_scale(x) Transformation with 245 nonmissing obs.
> Estimated statistics:
> - mean (before standardization) = 1149
> - sd (before standardization) = 633
> [1] "blastintensity.duration.first"
> orderNorm Transformation with 245 nonmissing obs and ties
> - 59 unique values
> - Original quantiles:
> 0% 25% 50% 75% 100%
> 0 2000 7000 13300 20000
> [1] "KIMS"
> Standardized asinh(x) Transformation with 245 nonmissing obs.:
> Relevant statistics:
> - mean (before standardization) = 1.9
> - sd (before standardization) = 0.13
> [1] "BSCS"
> Standardized asinh(x) Transformation with 245 nonmissing obs.:
> Relevant statistics:
> - mean (before standardization) = 2
> - sd (before standardization) = 0.22
> [1] "BAQ"
> Standardized asinh(x) Transformation with 245 nonmissing obs.:
> Relevant statistics:
> - mean (before standardization) = 1.8
> - sd (before standardization) = 0.3
> [1] "SOPT"
> Standardized asinh(x) Transformation with 245 nonmissing obs.:
> Relevant statistics:
> - mean (before standardization) = -3.1
> - sd (before standardization) = 0.69
> [1] "IAT"
> center_scale(x) Transformation with 245 nonmissing obs.
> Estimated statistics:
> - mean (before standardization) = -0.51
> - sd (before standardization) = 0.37
col.list <- paste0(col.list, ".BN")Let’s check if normality was corrected.
# Group normality
sapply(col.list, function(x)
nice_normality(data,
x,
"condition",
shapiro = TRUE,
title = x),
USE.NAMES = TRUE,
simplify = FALSE)> $blastintensity.BN
>
> $blastduration.BN
>
> $blastintensity.duration.BN
>
> $blastintensity.first.BN
>
> $blastduration.first.BN
>
> $blastintensity.duration.first.BN
>
> $KIMS.BN
>
> $BSCS.BN
>
> $BAQ.BN
>
> $SOPT.BN
>
> $IAT.BN
Looks rather reasonable now, though not perfect (fortunately t-tests are quite robust against violations of normality). We can now resume with the next step: checking variance.
# Plotting variance
plots(lapply(col.list, function(x) {
nice_varplot(data, x, group = "condition")
}),
n_columns = 3)Variance looks good. No group has four times the variance of any other group. We can now resume with checking outliers.
# Using boxplots
plots(lapply(col.list, function(x) {
ggplot(data, aes(condition, !!sym(x))) +
geom_boxplot()
}),
n_columns = 3)There are some outliers, but nothing unreasonable. Let’s still check with the 3 median absolute deviations (MAD) method.
find_mad(data, col.list, criteria = 3)> 6 outlier(s) based on 3 median absolute deviations for variable(s):
> blastintensity.BN blastduration.BN blastintensity.duration.BN blastintensity.first.BN blastduration.first.BN blastintensity.duration.first.BN KIMS.BN BSCS.BN BAQ.BN SOPT.BN IAT.BN
>
> Outliers per variable:
> $BSCS.BN
> Row BSCS.BN
> 1 242 -4.4
>
> $SOPT.BN
> Row SOPT.BN
> 1 61 4.4
> 2 84 3.2
> 3 90 3.2
> 4 218 4.4
>
> $IAT.BN
> Row IAT.BN
> 1 54 2.7
# 6 people after our transformationsVisual assessment and the MAD method confirm we have some outlier values. We could ignore them but because they could have disproportionate influence on the models, one recommendation is to winsorize them by bringing the values at 3 SD. Instead of using the standard deviation around the mean, however, we use the absolute deviation around the median, as it is more robust to extreme observations. For a discussion, see:
Leys, C., Klein, O., Bernard, P., & Licata, L. (2013). Detecting outliers: Do not use standard deviation around the mean, use absolute deviation around the median. Journal of Experimental Social Psychology, 49(4), 764–766. https://doi.org/10.1016/j.jesp.2013.03.013
# Winsorize variables of interest with MAD
data <- data %>%
mutate(across(all_of(col.list),
winsorize_mad,
.names = "{.col}.w"))
# Update col.list
col.list <- paste0(col.list, ".w")Outliers are still present but were brought back within reasonable limits, where applicable. We are now ready to compare the group condition (Control vs. Mindfulness Priming) across our different variables with the t-tests.
nice_t_test(data,
response = col.list,
group = "condition") %>%
nice_table(highlight = 0.10)> Using Welch t-test (base R's default; cf. https://doi.org/10.5334/irsp.82).
> For the Student t-test, use `var.equal = TRUE`.
>
>
Dependent Variable | t | df | p | d | 95% CI |
blastintensity.BN.w | -1.69 | 235.03 | .092 | -0.22 | [-0.47, 0.03] |
blastduration.BN.w | -0.69 | 238.85 | .491 | -0.09 | [-0.34, 0.16] |
blastintensity.duration.BN.w | -1.35 | 235.28 | .177 | -0.17 | [-0.42, 0.08] |
blastintensity.first.BN.w | 0.15 | 239.90 | .882 | 0.02 | [-0.23, 0.27] |
blastduration.first.BN.w | 0.25 | 241.71 | .800 | 0.03 | [-0.22, 0.28] |
blastintensity.duration.first.BN.w | 0.14 | 240.64 | .893 | 0.02 | [-0.23, 0.27] |
KIMS.BN.w | -0.87 | 238.36 | .383 | -0.11 | [-0.36, 0.14] |
BSCS.BN.w | -0.74 | 241.85 | .459 | -0.09 | [-0.34, 0.16] |
BAQ.BN.w | 1.34 | 241.81 | .182 | 0.17 | [-0.08, 0.42] |
SOPT.BN.w | -0.55 | 236.69 | .583 | -0.07 | [-0.32, 0.18] |
IAT.BN.w | 1.33 | 242.70 | .184 | 0.17 | [-0.08, 0.42] |
Interpretation: There is no clear group effect from our experimental condition on our different variables. However, there is a marginal effect of condition on blast intensity, whereas the mindfulness group has slightly higher blast intensity than the control group. Let’s visualize this effect.
nice_violin(data,
group = "condition",
response = "blastintensity.BN.w",
comp1 = 1,
comp2 = 2,
obs = TRUE)nice_violin(data,
group = "condition",
response = "blastduration.BN.w",
comp1 = 1,
comp2 = 2,
obs = TRUE)nice_violin(data,
group = "condition",
response = "blastintensity.duration.BN.w",
comp1 = 1,
comp2 = 2,
obs = TRUE)Let’s extract the means and standard deviations for journal reporting.
data %>%
group_by(condition) %>%
summarize(M = mean(blastintensity),
SD = sd(blastintensity),
N = n()) %>%
nice_table(width = 0.40)condition | M | SD | N |
Control | 4.38 | 2.32 | 128 |
Mindfulness | 4.93 | 2.57 | 117 |
data %>%
group_by(condition) %>%
summarize(M = mean(blastduration),
SD = sd(blastduration),
N = n()) %>%
nice_table(width = 0.40)condition | M | SD | N |
Control | 1,019.01 | 440.26 | 128 |
Mindfulness | 1,061.38 | 471.63 | 117 |
data %>%
group_by(condition) %>%
summarize(M = mean(blastintensity.duration),
SD = sd(blastintensity.duration),
N = n()) %>%
nice_table(width = 0.40)condition | M | SD | N |
Control | 5,368.70 | 4,245.46 | 128 |
Mindfulness | 6,356.67 | 5,041.47 | 117 |
Let’s see if our variables don’t interact together with our experimental condition. But first, let’s test the models assumptions.
big.mod1 <- lm(blastintensity.BN.w ~ condition_dum*KIMS.BN.w +
condition_dum*BSCS.BN.w + condition_dum*BAQ.BN.w +
condition_dum*SOPT.BN.w + condition_dum*IAT.BN.w,
data = data, na.action="na.exclude")
check_model(big.mod1)The model assumptions look really good actually, even with all these variables [less true now with the standardization and winsorization!]. Let’s look at the results.
big.mod2 <- lm(blastduration.BN.w ~ condition_dum*KIMS.BN.w +
condition_dum*BSCS.BN.w + condition_dum*BAQ.BN.w +
condition_dum*SOPT.BN.w + condition_dum*IAT.BN.w,
data = data, na.action="na.exclude")
check_model(big.mod2)The model assumptions look really good actually, even with all these variables [less true now with the standardization and winsorization!]. Let’s look at the results.
big.mod3 <- lm(blastintensity.duration.BN.w ~ condition_dum*KIMS.BN.w +
condition_dum*BSCS.BN.w + condition_dum*BAQ.BN.w +
condition_dum*SOPT.BN.w + condition_dum*IAT.BN.w,
data = data, na.action="na.exclude")
check_model(big.mod3)The model assumptions look really good actually, even with all these variables [less true now with the standardization and winsorization!]. Let’s look at the results.
big.mod1 %>%
nice_lm() %>%
nice_table(highlight = TRUE)Dependent Variable | Predictor | df | b | t | p | sr2 |
blastintensity.BN.w | condition_dum | 233 | 0.25 | 2.10 | .036 | .02 |
blastintensity.BN.w | KIMS.BN.w | 233 | 0.15 | 1.52 | .130 | .01 |
blastintensity.BN.w | BSCS.BN.w | 233 | -0.17 | -1.79 | .075 | .01 |
blastintensity.BN.w | BAQ.BN.w | 233 | 0.08 | 0.82 | .414 | .00 |
blastintensity.BN.w | SOPT.BN.w | 233 | -0.27 | -2.71 | .007 | .03 |
blastintensity.BN.w | IAT.BN.w | 233 | 0.17 | 1.99 | .048 | .01 |
blastintensity.BN.w | condition_dum:KIMS.BN.w | 233 | -0.20 | -1.44 | .151 | .01 |
blastintensity.BN.w | condition_dum:BSCS.BN.w | 233 | 0.51 | 3.39 | .001 | .04 |
blastintensity.BN.w | condition_dum:BAQ.BN.w | 233 | 0.05 | 0.37 | .708 | .00 |
blastintensity.BN.w | condition_dum:SOPT.BN.w | 233 | -0.10 | -0.76 | .451 | .00 |
blastintensity.BN.w | condition_dum:IAT.BN.w | 233 | -0.16 | -1.26 | .210 | .01 |
Interpretation: There is one significant interaction: condition by trait self-control (brief self-control scale, BSCS). However, there are marginally significant interactions, with BAQ and IAT (as expected), but not with SOPT.
Interpretation: Again, there seems to be an interaction between condition and self-control. However, there are also effects of the IAT, of SOPT, and of condition. [Note: it seems that after standardizing and winsorizing, the effects of condition and IAT go from significant to marginally significant only.]
big.mod2 %>%
nice_lm() %>%
nice_table(highlight = TRUE)Dependent Variable | Predictor | df | b | t | p | sr2 |
blastduration.BN.w | condition_dum | 233 | 0.13 | 1.11 | .270 | .00 |
blastduration.BN.w | KIMS.BN.w | 233 | 0.11 | 1.13 | .260 | .00 |
blastduration.BN.w | BSCS.BN.w | 233 | -0.14 | -1.50 | .134 | .01 |
blastduration.BN.w | BAQ.BN.w | 233 | 0.03 | 0.31 | .754 | .00 |
blastduration.BN.w | SOPT.BN.w | 233 | -0.32 | -3.33 | .001 | .04 |
blastduration.BN.w | IAT.BN.w | 233 | 0.22 | 2.62 | .009 | .02 |
blastduration.BN.w | condition_dum:KIMS.BN.w | 233 | -0.18 | -1.35 | .179 | .01 |
blastduration.BN.w | condition_dum:BSCS.BN.w | 233 | 0.52 | 3.52 | .001 | .04 |
blastduration.BN.w | condition_dum:BAQ.BN.w | 233 | 0.09 | 0.69 | .489 | .00 |
blastduration.BN.w | condition_dum:SOPT.BN.w | 233 | -0.07 | -0.50 | .618 | .00 |
blastduration.BN.w | condition_dum:IAT.BN.w | 233 | -0.16 | -1.31 | .192 | .01 |
big.mod3 %>%
nice_lm() %>%
nice_table(highlight = TRUE)Dependent Variable | Predictor | df | b | t | p | sr2 |
blastintensity.duration.BN.w | condition_dum | 233 | 0.21 | 1.82 | .070 | .01 |
blastintensity.duration.BN.w | KIMS.BN.w | 233 | 0.15 | 1.48 | .141 | .01 |
blastintensity.duration.BN.w | BSCS.BN.w | 233 | -0.17 | -1.76 | .080 | .01 |
blastintensity.duration.BN.w | BAQ.BN.w | 233 | 0.07 | 0.71 | .475 | .00 |
blastintensity.duration.BN.w | SOPT.BN.w | 233 | -0.31 | -3.11 | .002 | .03 |
blastintensity.duration.BN.w | IAT.BN.w | 233 | 0.20 | 2.33 | .021 | .02 |
blastintensity.duration.BN.w | condition_dum:KIMS.BN.w | 233 | -0.22 | -1.63 | .105 | .01 |
blastintensity.duration.BN.w | condition_dum:BSCS.BN.w | 233 | 0.56 | 3.75 | < .001 | .05 |
blastintensity.duration.BN.w | condition_dum:BAQ.BN.w | 233 | 0.08 | 0.61 | .541 | .00 |
blastintensity.duration.BN.w | condition_dum:SOPT.BN.w | 233 | -0.08 | -0.61 | .540 | .00 |
blastintensity.duration.BN.w | condition_dum:IAT.BN.w | 233 | -0.16 | -1.33 | .186 | .01 |
Let’s plot the main significant interaction(s).
# Plot
interact_plot(big.mod1, pred = "condition_dum", modx = "BSCS.BN.w",
modxvals = NULL, interval = TRUE)Interpretation: For people with low self-control, the priming mindfulness condition (cond = 1) seems to have little effect on blast intensity relative to the control condition (cond = 0). In contrast, for people with high self-control, the priming mindfulness condition relates to higher blast intensity.
# Plot
interact_plot(big.mod2, pred = "condition_dum", modx = "BSCS.BN.w",
modxvals = NULL, interval = TRUE)Interpretation: For people with low self-control, the priming mindfulness condition (cond = 1) seems to have little effect on blast intensity relative to the control condition (cond = 0). In contrast, for people with high self-control, the priming mindfulness condition relates to higher blast intensity.
# Plot
interact_plot(big.mod3, pred = "condition_dum", modx = "BSCS.BN.w",
modxvals = NULL, interval = TRUE)Interpretation: For people with low self-control, the priming mindfulness condition (cond = 1) seems to have little effect on blast intensity relative to the control condition (cond = 0). In contrast, for people with high self-control, the priming mindfulness condition relates to higher blast intensity.
Let’s look at the simple slopes now (only for the significant interaction).
big.mod1 %>%
nice_lm_slopes(predictor = "condition_dum",
moderator = "BSCS.BN.w") %>%
nice_table(highlight = TRUE)Dependent Variable | Predictor (+/-1 SD) | df | b | t | p | sr2 |
blastintensity.BN.w | condition_dum (LOW-BSCS.BN.w) | 233 | -0.25 | -1.30 | .193 | .01 |
blastintensity.BN.w | condition_dum (MEAN-BSCS.BN.w) | 233 | 0.25 | 2.10 | .036 | .02 |
blastintensity.BN.w | condition_dum (HIGH-BSCS.BN.w) | 233 | 0.74 | 3.99 | < .001 | .06 |
Interpretation: The effect of priming mindfulness on blast intensity is only significant for people with a high self-control.
big.mod2 %>%
nice_lm_slopes(predictor = "condition_dum",
moderator = "BSCS.BN.w") %>%
nice_table(highlight = TRUE)Dependent Variable | Predictor (+/-1 SD) | df | b | t | p | sr2 |
blastduration.BN.w | condition_dum (LOW-BSCS.BN.w) | 233 | -0.38 | -2.03 | .044 | .01 |
blastduration.BN.w | condition_dum (MEAN-BSCS.BN.w) | 233 | 0.13 | 1.11 | .270 | .00 |
blastduration.BN.w | condition_dum (HIGH-BSCS.BN.w) | 233 | 0.64 | 3.46 | .001 | .04 |
big.mod3 %>%
nice_lm_slopes(predictor = "condition_dum",
moderator = "BSCS.BN.w") %>%
nice_table(highlight = TRUE)Dependent Variable | Predictor (+/-1 SD) | df | b | t | p | sr2 |
blastintensity.duration.BN.w | condition_dum (LOW-BSCS.BN.w) | 233 | -0.33 | -1.76 | .080 | .01 |
blastintensity.duration.BN.w | condition_dum (MEAN-BSCS.BN.w) | 233 | 0.21 | 1.82 | .070 | .01 |
blastintensity.duration.BN.w | condition_dum (HIGH-BSCS.BN.w) | 233 | 0.76 | 4.09 | < .001 | .06 |
Based on the results, it seems that the interaction came up for all three of blast itensity, duration, and the combination of the two. Therefore, perhaps it does make sense to use the combination in future studies.
The full script of executive code contained in this document is reproduced here.
# Set up the environment (or use local alternative `source("utils/config.R")`)
source("utils/config.R")
fast <- FALSE # Make this true to skip the chunks
# This chunk is a bit complex so don't worry about it: it's made to add badges to the HTML versions
# NOTE: You have to replace the links accordingly to have working "buttons" on the HTML versions
if (!knitr::is_latex_output() && knitr::is_html_output()) {
cat("[](https://github.com/rempsyc/rempsyc/actions)
[](https://realitybending.github.io/TemplateResults/)
[](https://remi-theriault.com/word_and_pdf/SupplementaryMaterials.docx)
[](https://remi-theriault.com/word_and_pdf/SupplementaryMaterials.pdf)")
}
library(rempsyc)
library(dplyr)
library(interactions)
library(performance)
library(see)
library(patchwork)
library(ggplot2)
library(rstatix)
library(forecast)
library(DescTools)
library(report)
library(bestNormalize)
summary(report::report(sessionInfo()))
df <- read.csv("data/data.csv")
data <- read.csv("data/fulldataset.csv")
cat(paste("The data consists of",
report::report_participants(data),
". There are no demographics available."))
# Dummy-code group variable
data <- data %>%
mutate(condition_dum = ifelse(condition == "Mindfulness", 1, 0),
condition = as.factor(condition))
# Allocation ratio
cat(paste("The allocation ratio is: ",
report::report(data$condition)))
# Make list of DVs
col.list <- c("blastintensity", "blastduration", "blastintensity.duration",
"blastintensity.first", "blastduration.first",
"blastintensity.duration.first", "KIMS", "BSCS", "BAQ",
"SOPT", "IAT")
# Create new variable blastintensity.duration
data$blastintensity.duration <- (data$blastintensity * data$blastduration)
data$blastintensity.duration.first <- (data$blastintensity.first *
data$blastduration.first)
# Divide by 2? Do some other sort of transformation given I multiplied two scores?
# Should I multiply them after standardization or before?
# Standardize and center main continuous IV variable (based on MAD)
# data <- data %>%
# mutate(across(all_of(col.list),
# ~as.numeric(.x), #scale_mad(.x),
# .names = "{col}.mad"))
# We avoid standardizing now because it creates problems with the bestNormalize() function, and the latter also standardize variables anyway (although not based on mad...)
# Rename col.list with the MAD extension
# col.list <- paste0(col.list, ".mad")
report::cite_packages(sessionInfo())
# Group normality
sapply(col.list, function(x)
nice_normality(data,
x,
"condition",
shapiro = TRUE,
title = x),
USE.NAMES = TRUE,
simplify = FALSE)
# <!-- Normally, the SOPT raw scores represent the number of errors, but I had multiplied it by -1 initially so that a smaller score would mean lower working memory capacity. Here we reverse it again to be able to use the various transformations. -->
#
# <!-- We also add a constant of 1 to avoid scores of zero which can interfere with the transformation. We will use the Box-Cox transformation to be able to specify an optimal transformation ratio. -->
# Not necessary anymore since we use the `bestNormalize` package.
predict_bestNormalize <- function(var, print.transform = TRUE) {
x <- bestNormalize(var, standardize = TRUE)
if (print.transform == TRUE) {
print(cur_column())
print(x$chosen_transform)
}
predict(x)
}
set.seed(100)
data <- data %>%
mutate(across(all_of(col.list),
predict_bestNormalize,
.names = "{.col}.BN"))
col.list <- paste0(col.list, ".BN")
# Group normality
sapply(col.list, function(x)
nice_normality(data,
x,
"condition",
shapiro = TRUE,
title = x),
USE.NAMES = TRUE,
simplify = FALSE)
# Plotting variance
plots(lapply(col.list, function(x) {
nice_varplot(data, x, group = "condition")
}),
n_columns = 3)
# Using boxplots
plots(lapply(col.list, function(x) {
ggplot(data, aes(condition, !!sym(x))) +
geom_boxplot()
}),
n_columns = 3)
find_mad(data, col.list, criteria = 3)
# 6 people after our transformations
# Winsorize variables of interest with MAD
data <- data %>%
mutate(across(all_of(col.list),
winsorize_mad,
.names = "{.col}.w"))
# Update col.list
col.list <- paste0(col.list, ".w")
nice_t_test(data,
response = col.list,
group = "condition") %>%
nice_table(highlight = 0.10)
nice_violin(data,
group = "condition",
response = "blastintensity.BN.w",
comp1 = 1,
comp2 = 2,
obs = TRUE)
nice_violin(data,
group = "condition",
response = "blastduration.BN.w",
comp1 = 1,
comp2 = 2,
obs = TRUE)
nice_violin(data,
group = "condition",
response = "blastintensity.duration.BN.w",
comp1 = 1,
comp2 = 2,
obs = TRUE)
data %>%
group_by(condition) %>%
summarize(M = mean(blastintensity),
SD = sd(blastintensity),
N = n()) %>%
nice_table(width = 0.40)
data %>%
group_by(condition) %>%
summarize(M = mean(blastduration),
SD = sd(blastduration),
N = n()) %>%
nice_table(width = 0.40)
data %>%
group_by(condition) %>%
summarize(M = mean(blastintensity.duration),
SD = sd(blastintensity.duration),
N = n()) %>%
nice_table(width = 0.40)
big.mod1 <- lm(blastintensity.BN.w ~ condition_dum*KIMS.BN.w +
condition_dum*BSCS.BN.w + condition_dum*BAQ.BN.w +
condition_dum*SOPT.BN.w + condition_dum*IAT.BN.w,
data = data, na.action="na.exclude")
check_model(big.mod1)
big.mod2 <- lm(blastduration.BN.w ~ condition_dum*KIMS.BN.w +
condition_dum*BSCS.BN.w + condition_dum*BAQ.BN.w +
condition_dum*SOPT.BN.w + condition_dum*IAT.BN.w,
data = data, na.action="na.exclude")
check_model(big.mod2)
big.mod3 <- lm(blastintensity.duration.BN.w ~ condition_dum*KIMS.BN.w +
condition_dum*BSCS.BN.w + condition_dum*BAQ.BN.w +
condition_dum*SOPT.BN.w + condition_dum*IAT.BN.w,
data = data, na.action="na.exclude")
check_model(big.mod3)
big.mod1 %>%
nice_lm() %>%
nice_table(highlight = TRUE)
big.mod2 %>%
nice_lm() %>%
nice_table(highlight = TRUE)
big.mod3 %>%
nice_lm() %>%
nice_table(highlight = TRUE)
# Plot
interact_plot(big.mod1, pred = "condition_dum", modx = "BSCS.BN.w",
modxvals = NULL, interval = TRUE)
# Plot
interact_plot(big.mod2, pred = "condition_dum", modx = "BSCS.BN.w",
modxvals = NULL, interval = TRUE)
# Plot
interact_plot(big.mod3, pred = "condition_dum", modx = "BSCS.BN.w",
modxvals = NULL, interval = TRUE)
big.mod1 %>%
nice_lm_slopes(predictor = "condition_dum",
moderator = "BSCS.BN.w") %>%
nice_table(highlight = TRUE)
big.mod2 %>%
nice_lm_slopes(predictor = "condition_dum",
moderator = "BSCS.BN.w") %>%
nice_table(highlight = TRUE)
big.mod3 %>%
nice_lm_slopes(predictor = "condition_dum",
moderator = "BSCS.BN.w") %>%
nice_table(highlight = TRUE)report::cite_packages(sessionInfo())